package io.github.xyzboom.cj

import kotlin.test.Test
import kotlin.test.assertEquals

class LineBaseStringBuilderTest {
    @Test
    fun setLineShouldBeCorrect() {
        val sb = LineBasedStringBuilder()
        sb.set(1, 2, "123")
        assertEquals(" 123", sb.toString())
    }

    @Test
    fun setLineShouldBeCorrect2() {
        val sb = LineBasedStringBuilder()
        sb.set(1, 9, "class")
        sb.set(1, 15, "Data")
        assertEquals("${" ".repeat(8)}class Data", sb.toString())
    }

    @Test
    fun setLineShouldBeCorrectInMultiLine() {
        val sb = LineBasedStringBuilder()
        sb.set(1, 1, "class")
        sb.set(1, 7, "Data")
        sb.set(2, 1, "123")
        assertEquals("class Data\n123", sb.toString())
    }
}